<?php
	require_once('base.php');
	class SharePlugin extends BasePlugin	{		
		public function execute()	{
			//write to a temporary file
			$file = $this->pdf->getTempFile().".jpeg";
			file_put_contents($file, $this->pdf->getData());
			
			$url = "https://graph.facebook.com/me/photos";
			$params = array();
			$params['access_token'] = $_SESSION['access_token'];
			$params['source'] = "@".$file;
			$params['message'] = 'Created by IJDiagram';
			
			$ch = curl_init ();
			curl_setopt ( $ch, CURLOPT_URL, $url );
			curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
			curl_setopt ( $ch, CURLOPT_FOLLOWLOCATION, true );
			curl_setopt ( $ch, CURLOPT_POST, 1 );
			curl_setopt ( $ch, CURLOPT_POSTFIELDS, $params );
			curl_setopt ( $ch, CURLOPT_SSL_VERIFYHOST, 1 );
			$result = curl_exec ( $ch );
			echo $result;
		}
	} 
?>